import { DaemonCacheService } from '../../../../src/base/daemon/registry/daemon-cache-service';
import { DaemonState } from '../../../../src/base/daemon/registry/daemon-info';
import { HvigorLogger } from '../../../../src/base/log/hvigor-log';
import { hash } from '../../../../src/common/util/hash-util';

const daemonCacheJsonPath = process.argv[2];
const _log = HvigorLogger.getLogger();
const daemonCacheService = new DaemonCacheService(daemonCacheJsonPath, _log);
const defaultDaemonInfo = {
  address: '',
  cwdPath: '',
  hvigorVersion: '',
  nodeParams: hash(process.execArgv.toString()),
  nodeVersion: '',
  pid: 0,
  port: 0,
  state: DaemonState.IDLE,
  lastUsedTime: Date.now()
};
Array.from(Array.of(100).keys()).forEach(i=>{
  daemonCacheService.set(i.toString(), {
    keyId: i.toString(),
    ...defaultDaemonInfo
  });
});

Array.from(Array.of(100).keys()).forEach(i=>{
  daemonCacheService.get(i.toString());
  return daemonCacheService.remove(i.toString());
});
